#define  _CRT_SECURE_NO_WARNINGS 1
#include"Date.h"

Date::Date(int year = 1, int month=1, int day=1)
{
	_year = year;
	_month = month;
	_day = day;
}

bool Date::operator==(Date d)
{
	return _year == d._year && _month == d._month && _day == d._day;
}
bool Date::operator>(Date d)
{
	if (_year > d._year)
	{
		return true;
	}
	if (_year == d._year&&_month>d._month)
	{
		return true;
	}
	if (_year == d._year && _month == d._month && _day > d._day)
	{
		return true;
	}

	return false;
}
bool Date::operator>=(Date d)
{
	return ((*this).operator>(d)||(*this).operator==(d));
}
bool Date::operator<(Date d)
{
	return !((*this).operator>=(d));
}
bool Date::operator<=(Date d)
{
	return !(*this).operator>(d);
}
bool Date::operator!=(Date d)
{
	return !(*this).operator==(d);
}

int Date::GetDay()
{
	int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,30 };
	if (_month == 2 && ((_year % 4 == 0 && _year % 100 != 0) || _year % 400 == 0))
	{
		return 29;
	}
	return arr[_year];
}

Date& Date::operator+=(int d)
{
	_day += d;
	while (_day > (*this).GetDay())
	{
		_day -= (*this).GetDay();
		_month++;
		if (_month == 13)
		{
			_month = 1;
			_year++;
		}
	}
	return *this;
}

Date Date::operator+(int d)
{
	Date tmp(*this);
	tmp += d;
	return tmp;
}
Date& Date::operator++()
{
	_day++;
	if (_day > (*this).GetDay())
	{
		_month++;
		_day = 1;
		if (_month == 13)
		{
			_month = 1;
			_year++;
		}
	}
	return *this;
}
Date Date::operator++(int)
{
	Date tmp(*this);
	_day++;
	if (_day > (*this).GetDay())
	{
		_month++;
		_day = 1;
		if (_month == 13)
		{
			_month = 1;
			_year++;
		}
	}
	return tmp;
}
//Date Date::operator-(Date d);
//Date Date::operator-=(Date d);